/**
 * Created by Dalyn on 2017/2/28.
 */
import React from "react";
import { hashHistory } from 'react-router';
import Confirm from '../../common/Confirm'
import ListOrderMutation from "./mutation/ListOrderMutation"
import Order_Item from './Order_Item'
import './css/IndentManage.css'
import Util from "../../util/Util"
import Reactkey from "../../util/ReactKey"
import "./css/ListOrder_SaleAndRe.css"
import Relay from "react-relay";
import GetSendDetailsMutation from "./mutation/GetSendDetailsMutation"
/*信息列表*/
export default class GoodsRecord extends React.Component{
    constructor(props){
        super(props);
        this.state={
            orders:[]
        };
        this.enid = sessionStorage.getItem('enterpriseId');
        this.data = '';
    }


    componentWillMount(){
        let oid = this.props.location.state.oid;
        this.oid = oid;
        this.data = this.props.location.state.data;
        Relay.Store.commitUpdate(
            new GetSendDetailsMutation({
                recordId: oid,
            }),
            {
                onFailure: () => {
                },
                onSuccess: (response) => {
                    let errorCode = response.getSendDetails.getSendDetails.errorCode;
                    if(errorCode=='0'){
                        let order = response.getSendDetails.getSendDetails.sendDetailss;
                        this.setState({
                            orders:order,
                        });
                    }
                }
            }
        )
    }



    handleclick(){

    }

    addDepartmenlist(){
        return this.state.orders.map((context,index)=>{
            let data = Util.dateFormat(context.sendDate);
            return (
                <thead>
                <tr className={index%2==0?"order_list_saleandre_from_trchange":"order_list_saleandre_from_tr"}>
                    <td className="order_list_saleandre_from_td order_list_saleandre_from_td_oid">{this.data}</td>
                    <td className="order_list_saleandre_from_td order_list_saleandre_from_td_partb">{context.goodsName}</td>
                    {
                      //<td className="order_list_saleandre_from_td order_list_saleandre_from_td_product">{context.goodsSize}</td>
                    }
                    <td className="order_list_saleandre_from_td order_list_saleandre_from_td_count">{Number(context.price).toFixed(2)}</td>
                    <td className="order_list_saleandre_from_td order_list_saleandre_from_td_money">{Number(context.quantity).toFixed(3)}</td>
                    <td className="order_list_saleandre_from_td order_list_saleandre_from_td_doit">{Number(context.remainingQuantity).toFixed(3)}</td>
                    <td className="order_list_saleandre_from_td order_list_saleandre_from_td_end">{context.sendQuantity}</td>
                </tr>
                </thead>
            );
        });
    }

    stroke(){

    }

    status(){
        return this.oArr.map((item,index)=>{
            return (
                <span style={{width:80,height:27,borderRadius:"8px",background:"#ccc",display:"block"}} onClick={this.stroke.bind(this)}>{item}</span>
            )
        })
    }

    createorder(){
        hashHistory.push('/createorder')
    }

    onSure(size,num){
        this.queryorderlist(size,num);
    }

    render(){
        return (
            <div className="order_box" style={{width:1233,minHeight:475,background:"#f5f5f5",paddingTop:"20px"}}>
                <div style={{width:1195,minHeight:"592px",background:"#fff",marginTop:"20px",padding:"38px 19px 0 19px",position:"relative"}}>
                    <table className="order_list_saleandre_form_table">
                        <thead>
                        <tr className="order_list_saleandre_from_tr">
                            <td className="order_list_saleandre_from_td order_list_saleandre_goodrecord_time">发货时间</td>
                            <td className="order_list_saleandre_from_td order_list_saleandre_goodrecord_name">品名</td>
                          {
                            //  <td className="order_list_saleandre_from_td order_list_saleandre_goodrecord_size">规格/尺码</td>
                          }
                            <td className="order_list_saleandre_from_td order_list_saleandre_goodrecord_price">单价</td>
                            <td className="order_list_saleandre_from_td order_list_saleandre_goodrecord_end">数量</td>
                            <td className="order_list_saleandre_from_td order_list_saleandre_goodrecord_end">剩余数量</td>
                            <td className="order_list_saleandre_from_td order_list_saleandre_goodrecord_end">发货数量</td>
                        </tr>
                        </thead>
                        {
                            this.addDepartmenlist()
                        }
                    </table>
                </div>
            </div>

        )
    }
}
